/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package tablasSql;

import java.sql.ResultSet;
import java.sql.SQLException;
import otros.MiTableModel;

/**
 *
 * @author FERRETERIA
 */
public class RegStock {
        
    public static ResultSet getStockArt (String cod) {
        String sql = "Select * from regStock where articulo = '" + cod + "'";
        return new Sql().getDatos(sql);
    }
    
    public static void guardar (String [] datos, boolean guardar) {
        String sql = "";   
        int numString = 0;
        if (!guardar) {
           sql = "update regStock set fecha = ?, cantidad = ? ";
           sql += "where articulo = ?";
           numString = 3;
        }
        else {
            sql = "insert into regStock (articulo, fecha, cantidad values (?,?,?,?)";
            numString = 4;
        }
        new Sql().actualizarDatos(sql, datos, numString,0);
    }
    
    public static void guardar (String [] datos) {
        String sql = "insert into regStock (articulo, fecha, cantidad) values (?,?,?)";
        new Sql().actualizarDatos(sql, datos, 2,0);    
    }
    
    public static void borrar(String id) {
        String sql = "delete from regStock where articulo = " + id;
        new Sql().hacerConsulta(sql);
    }  
}
